package xyz.chaobei.thread.group;

import lombok.extern.slf4j.Slf4j;

/**
 * @copyright (C), 2015-2020
 * @fileName: ThreadGroupTest
 * @author: MRC
 * @date: 2021/1/28 23:12
 * @description:
 */
@Slf4j
public class ThreadGroupTest {

    public static void main(String[] args) {

        ThreadGroup group = new ThreadGroup("my-group") {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                log.error("线程异常处理，name={}", t.getName());
                log.error("线程异常处理", e);
            }
        };

        Thread thread = new Thread(group, () -> {
            System.out.println("线程执行。。。");
            throw new RuntimeException("主动抛出异常");
        });

        log.info("thread name={}", thread.getName());
        thread.start();

    }

}
